<template>
  <div class="page-employList">
    <!-- 累计消费情况 -->
    <div class="e-header">
      <div class="e-time">
        <h2>{{totalTime}}<i>小时</i></h2>
        <p>累计充电时长</p>
      </div>
      <div class="e-money">
        <h2>{{(totalMoney/100).toFixed(2)}}<i>元</i></h2>
        <p>累计消费金额</p>
      </div>
    </div>

    <!-- 员工消费列表 -->

    <div class="e-list" >
        <div v-show="list.length!=0" @click="GoEmployDetails(item.id)" v-bind:key="index" v-for="(item, index) in list" class="e-item">
          <div class="e-icon">
            <img v-bind:src="item.avator" />
          </div>
          <div class="e-name">{{item.name}}</div>
          <div class="e-tel">{{item.phone}}</div>
        </div>

        <div v-show="list.length==0" class="e-item-null">
          <div class="e-item-txt">暂无员工信息</div>
        </div>

    </div>


    <div class="page-bottom">
      <div @click="AddEmploy" class="e-btn">企业邀请码</div>
    </div>
  </div>
</template>

<script>
import { Popup } from "mint-ui";
export default {
  data() {
    return {
      avator: require("../public/imgs/icon-avator.png"),
      QrCodePopup: false,
      loadMoreFlag: false,
      totalMoney: "",
      totalTime: "",
      lists: [],
      list: []
    };
  },
  mounted() {
    // 加载更多
    this.init();
  },
  methods: {
    init() {
      var self = this;

      // 定义请求
      var req = this.Axios.get(this.Interface.Graphql, {
        params: self.GetQuery()
      });

      // 处理请求
      req.then(res => {
        var m = res.data.data.me;
        if (m != null) {
          if (m.company != null) {
            var com = m.company;
            self.totalMoney = com.totalAmount;
            self.totalTime = com.totalTime;
            if (com.users != null) {
              var users = com.users;
              users.forEach(item => {
                if (item.avator == null) {
                  item.avator = require("../public/imgs/icon-avator.png");
                }
              });
              self.list = users;
            } else {
              // self.list=[];
            }
          }
        }
      });
    },
    GetQuery() {
      return {
        query: `{
                me {
                  company {
                    totalTime
                    totalAmount
                    users{
                      id
                      name
                      phone
                      avatar
                    }
                  }
                }
              }
              `
      };
    },
    GoEmployDetails(id) {
      this.$router.push({
        path: "/employDetails",
        query: {
          id: id
        }
      });
    },
    AddEmploy() {
      this.$router.push("invitecode");
      //这里调用微信的分享功能，提供提示
    }
  }
};
</script>

<style lang="less" scoped>
.page-employList {
  position: relative;
  width: 100%;
  height: 100%;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  box-sizing: border-box;
  padding: 0 0 120px 0;
  background: #f3f3f3;
  .e-header {
    height: 150px;

    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border-bottom: 1px solid #ececec;
    & > div {
      -webkit-box-flex: 1;
      box-sizing: border-box;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-box-pack: center;
      -webkit-box-align: center;
      padding: 30px;
      h2 {
        font-size: 50px;
        margin-bottom: 10px;
        color: #2992ed;
        i {
          font-style: normal;
          font-size: 24px;
        }
      }
    }
  }
  .e-list {
    -webkit-box-flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    // padding:20px 0;
  }
}

.e-item {
  position: relative;
  border-bottom: 1px solid #ececec;
  box-sizing: border-box;
  padding: 30px;
  font-size: 26px;
  color: #333;
  padding-left: 140px;
  line-height: 35px;
  background: #fff;

  .e-icon {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translate(0, -50%);
    width: 85px;
    height: 85px;
    img {
      display: block;
      width: 100%;
      height: 100%;
    }
  }
  .e-name {
    width: 100%;
    height: 35px;
    overflow: hidden;
    font-size: 28px;
    margin: 0 0 10px 0;
  }
  .e-tel {
    color: #717171;
  }
}

.e-item-null {
  display: -webkit-box;
  box-sizing: border-box;
  padding: 50px 0 0 0;
  -webkit-box-pack: center;
  -webkit-box-align: center;
}

.page-bottom {
  position: fixed;
  left: 0;
  bottom: 0;
  border-top: 1px solid #ececec;
  height: 120px;
  box-sizing: border-box;
  width: 100%;
  padding: 20px 30px;
  background: #fcfbfb;
  .e-btn {
    text-align: center;
    background: #2992ed;
    color: #fff;
    font-size: 28px;
    width: 100%;
    height: 100%;
    line-height: 80px;
    border-radius: 5px;
  }
}
</style>



